import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

interface GeneralStack<E> {
	E push(E item);
	E pop();
	E peek();
	public boolean empty();
	public int size();
}

class Car{
	private int id;
	private String name;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Override
	public String toString() {
		return "Car [id=" + id + ", name=" + name + "]";
	}
	
}
class ArrayListGeneralStack<E> implements GeneralStack<E>{
	List<E> list = new ArrayList<E>();

	@Override
	public E push(E item) {
		if(item==null) return null;
		list.add( item);
		return item;
	}

	@Override
	public E pop() {
		if(list.size()==0)
			return null;
		else
			return list.remove(list.size()-1);
	}

	@Override
	public E peek() {
		if(list.size()==0)
			return null;
		else{
			return list.get(list.size()-1);
		}
	}

	@Override
	public boolean empty() {
		if(list.size()==0)
			return true;
			else
			return false;
	}

	@Override
	public int size() {
		return list.size();
	}
	
	public String toString(){
		 return list.toString();
	 }
}

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		while(true){
			String str=sc.nextLine();
			if(str.equals("quit")) break;
					
			if(str.equals("Integer")){
				int m=sc.nextInt();
				int n=sc.nextInt();
				System.out.println("Integer Test");
				ArrayListGeneralStack<Integer> ArrayListGeneralStack=new ArrayListGeneralStack<Integer>();
				for(int i=0;i<m;i++){
					int x=sc.nextInt();
					ArrayListGeneralStack.push(x);
					System.out.println("push:"+x);
				}
				for(int i=0;i<n;i++){
					System.out.println("pop:"+ArrayListGeneralStack.pop());
				}
				System.out.println(ArrayListGeneralStack.toString());
				int sum=0;
				while(!ArrayListGeneralStack.empty()){
					sum+=ArrayListGeneralStack.pop();
				}
				System.out.println("sum="+sum);
				System.out.println(ArrayListGeneralStack.getClass().getInterfaces()[0]);
			}
			
			if(str.equals("Double")){
				int m=sc.nextInt();
				int n=sc.nextInt();
				System.out.println("Double Test");
				ArrayListGeneralStack<Double> ArrayListGeneralStack=new ArrayListGeneralStack<Double>();
				for(int i=0;i<m;i++){
					double x=sc.nextDouble();
					ArrayListGeneralStack.push(x);
					System.out.println("push:"+x);
				}
				
				for(int i=0;i<n;i++){
					System.out.println("pop:"+ArrayListGeneralStack.pop());
				}
				System.out.println(ArrayListGeneralStack.toString());
				double sum=0;
				while(!ArrayListGeneralStack.empty()){
					sum+=ArrayListGeneralStack.pop();
				}
				System.out.println("sum="+sum);
				System.out.println(ArrayListGeneralStack.getClass().getInterfaces()[0]);
			}
			if(str.equals("Car")){
				int m=sc.nextInt();
				int n=sc.nextInt();
				System.out.println("Car Test");
				ArrayListGeneralStack<Car> ArrayListGeneralStack=new ArrayListGeneralStack<Car>();
				for(int i=0;i<m;i++){
					Car car=new Car();
					car.setId(sc.nextInt());
					car.setName(sc.next());
					ArrayListGeneralStack.list.add(car);
					System.out.println("push:"+car);
				}
				for(int i=0;i<n;i++){
					System.out.println("pop:"+ArrayListGeneralStack.pop());
				}
				System.out.println(ArrayListGeneralStack.toString());
				for(int i=0;i<m-n;i++){
					Car car= ArrayListGeneralStack.pop();
					System.out.println(car.getName());
				}
				System.out.println(ArrayListGeneralStack.getClass().getInterfaces()[0]);
			}
		}
	}

}


